package com.yyq.seven;

import org.junit.Test;

/**
 * @author yyq
 * @create 2021-08-04 13:29
 *
 */
public class SeaonTest {
    //定义枚举类 方式一 JDk5.0之前自定义枚举类
    //                JDK5.0之后 enum
    @Test
    public void test1(){
        System.out.println(Season.SPRING.getSeasoName());

    }

    @Test
    public void enum1(){
        System.out.println(Season1.AUTUM.getSeasonName());
        System.out.println(Season1.SPARING.getSeasonName());
        System.out.println(Season1.class.getSuperclass());
    }

}

class Season{

    //声明属性  :private final 修饰
    private final String seasoName;
    private final String seasoDesc;

    //私有化构造器 并给对象属性赋值
    private Season(String n,String d){
        this.seasoName=n;
        this.seasoDesc=d;
    }
    //提供当前枚举类多个对象
    public static final Season SPRING=new Season("春天","春暖花开");
    public static final Season SUMMER=new Season("夏天","夏日炎炎");

    //获取对象属性
    public String getSeasoName() {
        return this.seasoName;
    }

    public String getSeasoDesc() {
        return this.seasoDesc;
    }
}
interface info{
    void show();
}
//自定义enum
enum Season1 implements info{
    //1 提供多个对象 对象之间用逗号 末尾分号结束
    SPARING("春天","春暖花开"){
        @Override
        public void show() {
            System.out.println("这是春天呀");
        }
    },
    SUMMER("夏天","炎炎夏日"){
        @Override
        public void show() {
            System.out.println("这是夏天呀");
        }
    },
    AUTUM("秋天","秋高气爽") {
        @Override
        public void show() {
            System.out.println("这是秋天呀");
        }
    },
    WINER("冬天","天寒地冻") {
        @Override
        public void show() {
            System.out.println("这是冬天呀");
        }
    };


    //2 声明属性
    String seasonName;
    String seasonDesc;

    //3 构造器
    Season1(String name, String desc) {
    this.seasonName=name;
    this.seasonDesc=desc;
    }

    //4 get方法
    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }


}